package com.xbongbong.saas.model.impl;

import com.xbongbong.paas.domain.entity.StageWorkLogEntity;
import com.xbongbong.paas.toolbox.util.CollectionsUtil;
import com.xbongbong.saas.domain.dao.CustomerWorkLogDao;
import com.xbongbong.saas.domain.entity.CustomerWorkLogEntity;
import com.xbongbong.saas.model.CustomerWorkLogModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author haibin.zhang
 * @version v1.0
 * @date 2019/3/10 16:47
 * @since v1.0
 */
@Service("customerWorkLog")
public class CustomerWorkLogModelImpl implements CustomerWorkLogModel {

    @Resource
    private CustomerWorkLogDao customerWorkLogDao;

    @Override
    public List<CustomerWorkLogEntity> findEntitys(Map<String, Object> modelMap) {
        return customerWorkLogDao.findEntitys(modelMap);
    }

    @Override
    public void insertBatch(List<CustomerWorkLogEntity> customerWorkLogList) {
        if (CollectionsUtil.isNotEmpty(customerWorkLogList)) {
            customerWorkLogDao.insertBatch(customerWorkLogList);
        }
    }

    @Override
    public void save(CustomerWorkLogEntity customerWorkLogEntity) {
        if (customerWorkLogEntity.getId() == null){
            customerWorkLogDao.insert(customerWorkLogEntity);
        }else {
            customerWorkLogDao.update(customerWorkLogEntity);
        }
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return customerWorkLogDao.getEntitysCount(param);
    }
}
